home *** CD-ROM | disk | FTP | other *** search
- #include <tos.h>
-
-
- typedef struct
- { long magic;
- long freq;
- int r_seg;
- } SEGM_HEADER;
-
- const long IdentFreq[] = {'6.25', '12.5', '25.0', '50.0'};
-
- /* the DMA play back frequency */
- extern int PlayFreq;
-
-
-
- int LoadSegm(int f, int *rep_segm, long length, long *segm)
- {long *s, freq;
- char *image;
- SEGM_HEADER head;
-
- Fread(f, sizeof(SEGM_HEADER), &head); /* read the header */
- if (head.magic != 'SEGM')
- return 3;
-
- s = IdentFreq; /* get playback frequency from file */
- freq = 0;
- while(*s++ != head.freq)
- if (freq++ > 4)
- return 2;
-
- PlayFreq = 128 + (int)freq;
-
- *rep_segm = head.r_seg; /* get repeat segment from file */
-
- Fread(f, length, segm); /* read file into memory */
-
- /* find address of the sample image */
- s = segm;
- while (*s != -1)
- s += 2;
-
- image = (char *)(s + 2);
-
- /* Now fixup the sequence table, (offsets -> abs. addreses) */
- while (*segm != -1)
- { *segm = (long)(image + *segm);
- segm += 2;
- }
-
- return 0;
- }
-